import { request } from "../../request/index.js";
import regeneratorRuntime, { async } from '../../lib/runtime/runtime';

// pages/tips/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    arr: []
  },

  async onLoad () {
    const { data: res } = await request({
      url: '/tips/queryRandomTips'
    })
    const { data: res1 } = await request({
      url: '/tips/queryRandomTips'
    })
    this.setData ({
      arr: [res, res1]
    })
    console.log(this.data.arr)
  },

  async handleChange (e) {
    let { current } = e.detail;
    const res = await request({
      url: '/tips/queryRandomTips'
    })
    if (current) {
      current = 0
    } else {
      current = 1
    }
    this.data.arr[current] = res.data
    this.setData ({
      arr: this.data.arr
    })
    console.log(current)
    console.log(this.data.arr)
  }  
})